<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="98px">
      <el-form-item label="单位名称" prop="enterpriseName">
        <el-input
          v-model="queryParams.enterpriseName"
          placeholder="请输入单位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="资信等级" prop="creditRate">
        <el-input
          v-model="queryParams.creditRate"
          placeholder="资信等级"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地区" prop="region">
        <el-input
          v-model="queryParams.region"
          placeholder="请输入地区"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>



      <el-form-item label="注册资本" prop="registerCapital">
        <el-input
          v-model="queryParams.registerCapital"
          placeholder="请输入注册资本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="法人业务状态" prop="legalPersonStatus">
        <el-select v-model="queryParams.legalPersonStatus" placeholder="请选择法人业务状态" clearable>
          <el-option
            v-for="dict in dict.type.compete_unit_legal_person_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <!-- <el-button type="success" icon="el-icon-search" size="mini" @click='showHighSearch=!showHighSearch'>高级搜索</el-button> -->
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:compete_enterprise:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:compete_enterprise:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:compete_enterprise:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:compete_enterprise:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="compete_enterpriseList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="单位名称" align="left" header-align="center" prop="enterpriseName" width="210" fixed/>
      <!-- <el-table-column label="法人类别" align="center" prop="legalPersonType" />
      <el-table-column label="法人代码" align="center" prop="legalPersonNumber" />
      <el-table-column label="法人角色" align="center" prop="legalPersonRole" />
      <el-table-column label="营业执照号码" align="center" prop="businessNo" width="100"/>
      <el-table-column label="营业执照失效日期" align="center" prop="certificateExpiryDate" width="130">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.certificateExpiryDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="法定代表人姓名" align="center" prop="legalPersonName" width="180" />
      <!-- <el-table-column label="法人机构类别" align="center" prop="legalPersonCategory" width="100"/>
      <el-table-column label="法人机构行业代码" align="center" prop="legalPersonCategoryNo" width="130"/> -->
      <el-table-column label="资信等级" align="center" prop="creditRate" />
      <el-table-column label="地区" align="center" prop="region" />
      <!-- <el-table-column label="法人机构地址" align="center" prop="legalPersonAddress" width="180"/>
      <el-table-column label="注册地-省" align="center" prop="registerProvince" />
      <el-table-column label="注册地-市" align="center" prop="registerCity" /> -->
      <el-table-column label="注册资本" align="center" prop="registerCapital" />
      <!-- <el-table-column label="注册资本币种" align="center" prop="registerCapitalCurrency" width="100"/>
      <el-table-column label="联系人" align="center" prop="contacts" />
      <el-table-column label="联系人电话" align="center" prop="contactsPhone"  width="100"/>
      <el-table-column label="联系人地址" align="center" prop="contactsAddress" width="100" />
      <el-table-column label="单位网址" align="center" prop="website" />
      <el-table-column label="邮政编码" align="center" prop="postalCode" /> -->
      <el-table-column label="历史业绩" align="center">
        <template slot-scope="scope">
          <router-link :to="'/business/compete_enterprise_project-index/index/' + scope.row.enterpriseId" class="link-type">
            <span>{{ scope.row.enterpriseNumber.historyNumber }}</span>
          </router-link>
        </template>
      </el-table-column>
      <!-- <el-table-column label="企业证书" align="center" >
        <template slot-scope="scope">
          <router-link :to="'/business/compete_enterprise_certificate-index/index/' + scope.row.enterpriseId" class="link-type">
            <span>{{ scope.row.enterpriseNumber.awardNumber }}</span>
          </router-link>
        </template>
      </el-table-column> -->
      <el-table-column label="不良行为" align="center" >
        <template slot-scope="scope">
          <router-link :to="'/business/compete_bad_behavior-index/index/' + scope.row.enterpriseId" class="link-type">
            <span>{{ scope.row.enterpriseNumber.badBehaviorNumber }}</span>
          </router-link>
        </template>
      </el-table-column>
      <!-- <el-table-column label="法人业务状态" align="center" prop="legalPersonStatus" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.compete_unit_legal_person_status" :value="scope.row.legalPersonStatus"/>
        </template>
      </el-table-column> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="handleDetail(scope.row)"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:compete_enterprise:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:compete_enterprise:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改基本信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="180px">
        <el-row>
          <el-col :span="12">
        <el-form-item label="单位名称" prop="enterpriseName">
          <el-input v-model="form.enterpriseName" placeholder="请输入单位名称" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="法人代码" prop="legalPersonNumber">
          <el-input v-model="form.legalPersonNumber" placeholder="请输入法人代码" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="法人角色" prop="legalPersonRole">
          <el-input v-model="form.legalPersonRole" placeholder="请输入法人角色" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="营业执照号码" prop="businessNo">
          <el-input v-model="form.businessNo" placeholder="请输入营业执照号码" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="营业执照失效日期" prop="certificateExpiryDate">
          <el-date-picker clearable
            v-model="form.certificateExpiryDate"
            type="date"
            style="width: 302px"
            value-format="yyyy-MM-dd"
            placeholder="请选择营业执照失效日期">
          </el-date-picker>
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="法定代表人姓名" prop="legalPersonName">
          <el-input v-model="form.legalPersonName" placeholder="请输入法定代表人姓名" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="法人机构类别" prop="legalPersonCategory">
          <el-input v-model="form.legalPersonCategory" placeholder="请输入法人机构类别" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="法人机构行业代码" prop="legalPersonCategoryNo">
          <el-input v-model="form.legalPersonCategoryNo" placeholder="请输入法人机构行业代码" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="资信等级" prop="creditRate">
          <el-input v-model="form.creditRate" placeholder="请输入资信等级" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="地区" prop="region">
          <el-input v-model="form.region" placeholder="请输入地区" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="法人机构地址" prop="legalPersonAddress">
          <el-input v-model="form.legalPersonAddress" placeholder="请输入法人机构地址" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="注册地-省" prop="registerProvince">
          <el-input v-model="form.registerProvince" placeholder="请输入注册地-省" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="注册地-市" prop="registerCity">
          <el-input v-model="form.registerCity" placeholder="请输入注册地-市" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="注册资本" prop="registerCapital">
          <el-input v-model="form.registerCapital" placeholder="请输入注册资本" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="注册资本币种" prop="registerCapitalCurrency">
          <el-input v-model="form.registerCapitalCurrency" placeholder="请输入注册资本币种" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="联系人" prop="contacts">
          <el-input v-model="form.contacts" placeholder="请输入联系人" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="联系人电话" prop="contactsPhone">
          <el-input v-model="form.contactsPhone" placeholder="请输入联系人电话" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="联系人地址" prop="contactsAddress">
          <el-input v-model="form.contactsAddress" placeholder="请输入联系人地址" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="单位网址" prop="website">
          <el-input v-model="form.website" placeholder="请输入单位网址" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="邮政编码" prop="postalCode">
          <el-input v-model="form.postalCode" placeholder="请输入邮政编码" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
        <el-form-item label="法人业务状态">
          <el-radio-group v-model="form.legalPersonStatus">
            <el-radio
              v-for="dict in dict.type.compete_unit_legal_person_status"
              :key="dict.value"
:label="dict.value"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="法人类别" prop="legalPersonType">
          <el-input v-model="form.legalPersonType" placeholder="请输入法人类别" />
        </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 详情 -->
    <el-dialog title="竞争单位信息详情" :visible.sync="detailOpen" width="1100px" append-to-body>
      <el-form ref="detailForm" :model="detailForm"  label-width="180px">
        <el-row>
          <el-col :span="8">
        <el-form-item label="单位名称:" style="margin-bottom:0px;">
          <span>{{detailForm.enterpriseName}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="法人代码:" style="margin-bottom:0px;">
          <span>{{detailForm.legalPersonNumber}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="法人角色:" style="margin-bottom:0px;">
          <span>{{detailForm.legalPersonRole}}</span>
        </el-form-item>
          </el-col>
       </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item label="营业执照号码:" style="margin-bottom:0px;">
          <span>{{detailForm.businessNo}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="营业执照失效日期:" style="margin-bottom:0px;">
          <span>{{ parseTime(detailForm.certificateExpiryDate, '{y}-{m}-{d}') }}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="法定代表人姓名:" style="margin-bottom:0px;">
          <span>{{detailForm.legalPersonName}}</span>
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item label="法人机构类别:" style="margin-bottom:0px;">
          <span>{{detailForm.legalPersonCategory}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="法人机构行业代码:" style="margin-bottom:0px;">
          <span>{{detailForm.legalPersonCategoryNo}}</span>
        </el-form-item>
          </el-col>

          <el-col :span="8">
        <el-form-item label="资信等级:" style="margin-bottom:0px;">
          <span>{{detailForm.creditRate}}</span>
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item label="地区:" style="margin-bottom:0px;">
          <span>{{detailForm.region}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="法人机构地址:" style="margin-bottom:0px;">
          <span>{{detailForm.legalPersonAddress}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="注册地-省:" style="margin-bottom:0px;">
          <span>{{detailForm.registerProvince}}</span>
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item label="注册地-市:" style="margin-bottom:0px;">
          <span>{{detailForm.registerCity}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="注册资本:" style="margin-bottom:0px;">
          <span>{{detailForm.registerCapital}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="注册资本币种:" style="margin-bottom:0px;">
          <span>{{detailForm.registerCapitalCurrency}}</span>
        </el-form-item>
          </el-col>
       </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item label="联系人:" style="margin-bottom:0px;">
          <span>{{detailForm.contacts}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="联系人电话:" style="margin-bottom:0px;">
          <span>{{detailForm.contactsPhone}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="联系人地址:" style="margin-bottom:0px;">
          <span>{{detailForm.contactsAddress}}</span>
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item label="单位网址:" style="margin-bottom:0px;">
          <span>{{detailForm.website}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="邮政编码:" style="margin-bottom:0px;">
          <span>{{detailForm.postalCode}}</span>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="法人业务状态:" style="margin-bottom:0px;">
          <dict-tag :options="dict.type.compete_unit_legal_person_status" :value="detailForm.legalPersonStatus"/>
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item label="法人类别:" style="margin-bottom:0px;">
          <span>{{detailForm.legalPersonType}}</span>
        </el-form-item>
          </el-col>
        </el-row>

        <el-tabs type="border-card">
          <el-tab-pane>
            <span slot="label"><i class="el-icon-trophy"></i> 资质证书</span>

            <el-table :data="certificateList" :row-class-name="detailCertificateListIndex">
              <el-table-column label="竞争单位名称" align="center" prop="enterpriseName" width="110"/>
              <el-table-column label="证书名称" align="center" prop="certificateName" />
              <el-table-column label="资质类别" align="center" prop="certificateType">
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.pm_compete_qualit_category" :value="scope.row.certificateType"/>
                </template>
              </el-table-column>
              <el-table-column label="资质等级" align="center" prop="certificateGrade">
                <template slot-scope="scope">
                  <dict-tag :options="dict.type.pm_award_grade" :value="scope.row.certificateGrade"/>
                </template>
              </el-table-column>
              <el-table-column label="资质等级图片" align="center" prop="certificateImage" width="100">
                <template slot-scope="scope">
                  <image-preview :src="scope.row.certificateImage" :width="50" :height="50"/>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>


          <el-tab-pane >
            <span slot="label"><i class="el-icon-warning-outline"></i> 不良行为</span>

            <el-table :data="badBehaviorList" :row-class-name="badBehaviorListIndex">
              <el-table-column label="竞争单位名称" align="center" prop="enterpriseName" />
              <el-table-column label="不良行为名称" align="center" prop="behaviorName" />
              <el-table-column label="处罚单位" align="center" prop="punishUnit" />
              <el-table-column label="处罚区域" align="center" prop="punishRegion" />
              <el-table-column label="公示截图" align="center" prop="image" width="100">
                <template slot-scope="scope">
                  <image-preview :src="scope.row.image" :width="50" :height="50"/>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane >
            <span slot="label"><i class="el-icon-document"></i> 历史业绩</span>

            <el-table :data="historyProjectList" :row-class-name="historyProjectListIndex">
              <el-table-column label="竞争单位名称" align="center" prop="enterpriseName" width="100"/>
              <el-table-column label="工程名称" align="center" prop="projectName" />
              <el-table-column label="建设单位" align="center" prop="constructEnterprise" />
              <el-table-column label="中标时间" align="center" prop="bidDate" width="180">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.bidDate, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="中标金额" align="center" prop="bidAmount" />
              <el-table-column label="竣工时间" align="center" prop="completeTime" width="180">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.completeTime, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="项目经理" align="center" prop="projectManager" />
            </el-table>
          </el-tab-pane>

          <el-tab-pane >
            <span slot="label"><i class="el-icon-document"></i> 企业信用分</span>

            <el-table :data="gradeList" :row-class-name="gradeListIndex">
              <el-table-column label="竞争单位名称" align="center" prop="enterpriseName" />
              <el-table-column label="考核周期" align="center" prop="gradeName" />
              <el-table-column label="地区" align="center" prop="region" />
              <el-table-column label="评价分数" align="center" prop="score" />
              <el-table-column label="排名" align="center" prop="ranks" />
            </el-table>
          </el-tab-pane>

        </el-tabs>

      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { listCompete_enterprise,getAppCompete_enterprise, getCompete_enterprise, delCompete_enterprise, addCompete_enterprise, updateCompete_enterprise } from "@/api/business/compete_enterprise";

export default {
  name: "Compete_enterprise",
  dicts: ['compete_unit_legal_person_status','pm_award_grade', 'pm_compete_qualit_category','pm_period'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      //高级搜索
      showHighSearch: false,
      // 总条数
      total: 0,
      // 基本信息表格数据
      compete_enterpriseList: [],
      historyProjectList: [],
      gradeList: [],
      badBehaviorList: [],
      certificateList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      detailOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        enterpriseName: null,
        registerProvince: null,
        registerCity: null,
        registerCapital: null,
        legalPersonStatus: null
      },
      // 表单参数
      form: {},
      detailForm: {},
      // 表单校验
      rules: {
        enterpriseName: [
          { required: true, message: "单位名称不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询基本信息列表 */
    getList() {
      this.loading = true;
      listCompete_enterprise(this.queryParams).then(response => {
        this.compete_enterpriseList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        enterpriseId: null,
        enterpriseName: null,
        legalPersonType: null,
        legalPersonNumber: null,
        legalPersonRole: null,
        businessNo: null,
        certificateExpiryDate: null,
        legalPersonName: null,
        legalPersonCategory: null,
        legalPersonCategoryNo: null,
        creditRate: null,
        region: null,
        legalPersonAddress: null,
        registerProvince: null,
        registerCity: null,
        registerCapital: null,
        registerCapitalCurrency: null,
        contacts: null,
        contactsPhone: null,
        contactsAddress: null,
        website: null,
        postalCode: null,
        legalPersonStatus: "0"
      };
      this.detailForm = {
        enterpriseId: null,
        enterpriseName: null,
        legalPersonType: null,
        legalPersonNumber: null,
        legalPersonRole: null,
        businessNo: null,
        certificateExpiryDate: null,
        legalPersonName: null,
        legalPersonCategory: null,
        legalPersonCategoryNo: null,
        creditRate: null,
        region: null,
        legalPersonAddress: null,
        registerProvince: null,
        registerCity: null,
        registerCapital: null,
        registerCapitalCurrency: null,
        contacts: null,
        contactsPhone: null,
        contactsAddress: null,
        website: null,
        postalCode: null,
        legalPersonStatus: "0"
      };
      this.resetForm("form");
      this.resetForm("detailForm");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.enterpriseId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加基本信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const enterpriseId = row.enterpriseId || this.ids
      getCompete_enterprise(enterpriseId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改基本信息";
      });
    },
    /** 详情 */
    handleDetail(row) {
      this.reset();
      const enterpriseId = row.enterpriseId || this.ids
      getAppCompete_enterprise(enterpriseId).then(response => {
        this.detailForm = response.data;
        this.historyProjectList = response.data.historyProjectList;
        this.gradeList = response.data.gradeList;
        this.badBehaviorList = response.data.badBehaviorList;
        this.certificateList = response.data.certificateList;
        this.detailOpen = true;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.enterpriseId != null) {
            updateCompete_enterprise(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCompete_enterprise(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const enterpriseIds = row.enterpriseId || this.ids;
      var deleteTitle = row.enterpriseName? ('"'+row.enterpriseName+'"'):'';
      this.$modal.confirm('是否确认删除' + deleteTitle + '？').then(function() {
        return delCompete_enterprise(enterpriseIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/compete_enterprise/export', {
        ...this.queryParams
      }, `compete_enterprise_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
